//
//  YQRefundGoodInfoCell.m
//  MuYing
//
//  Created by caominglei on 2020/6/15.
//  Copyright © 2020 TBB. All rights reserved.
//

#import "YQRefundGoodInfoCell.h"

@implementation YQRefundGoodInfoCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)initView
{
    _titleLb = UILabel.new;
    _titleLb.text = @"我是HKD";
    _titleLb.textColor = HexColor(0x333333);
    _titleLb.font = kFont_Medium(15);
    [self.contentView addSubview:_titleLb];
    [_titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(12);
        make.top.mas_equalTo(12);
        make.height.mas_equalTo(30);
    }];
    
    _stateLb = UILabel.new;
    _stateLb.text = @"不可退款";
    _stateLb.textColor = HexColor(0x333333);
    _stateLb.font = kFont_Medium(15);
    [self.contentView addSubview:_stateLb];
    [_stateLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-12);
        make.top.mas_equalTo(12);
        make.height.mas_equalTo(30);
    }];
    
    _topPadView = UIView.new;
    _topPadView.backgroundColor = HexColor(0xCDCDCD);
    [self.contentView addSubview:_topPadView];
    [_topPadView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.left.mas_equalTo(0);
        make.top.mas_equalTo(self.titleLb.mas_bottom).offset(6);
        make.height.mas_equalTo(0.5);
    }];
    
    _icon = UIImageView.new;
    _icon.image = IMAGE_NAMED(@"");
    [self.contentView addSubview:_icon];
    [_icon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.mas_equalTo(88);
        make.left.mas_equalTo(12);
        make.top.mas_equalTo(self.topPadView.mas_bottom).offset(6);
    }];
    
    _labPrice = UILabel.new;
    _labPrice.text = @"我是HKD";
    _labPrice.textColor = HexColor(0x333333);
    _labPrice.font = kFont_Medium(15);
    [self.contentView addSubview:_labPrice];
    [_labPrice mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-12);
        make.top.mas_equalTo(self.icon.mas_top).offset(6);
    }];
    
    _labName = UILabel.new;
    _labName.text = @"我是商品";
    _labName.numberOfLines = 2;
    _labName.textColor = HexColor(0x333333);
    _labName.font = kFont_Medium(15);
    [self.contentView addSubview:_labName];
    [_labName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(self.labPrice.mas_left).offset(-12);
        make.left.mas_equalTo(self.icon.mas_right).offset(8);
        make.top.mas_equalTo(self.icon.mas_top).offset(6);
    }];
    
    _namePadView = UIView.new;
    _namePadView.backgroundColor = HexColor(0xCDCDCD);
    [self.contentView addSubview:_namePadView];
    [_namePadView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-12);
        make.left.mas_equalTo(self.icon.mas_right).offset(8);
        make.top.mas_equalTo(self.labName.mas_bottom).offset(6);
        make.height.mas_equalTo(0.5);
    }];
    
    _labAttr = UILabel.new;
    _labAttr.text = @"我是商品属性";
    _labAttr.textColor = HexColor(0x999999);
    _labAttr.font = kFont_Medium(13);
    [self.contentView addSubview:_labAttr];
    [_labAttr mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-12);
        make.left.mas_equalTo(self.icon.mas_right).offset(8);
        make.top.mas_equalTo(self.namePadView.mas_bottom).offset(6);
    }];
    
    _attrPadView = UIView.new;
    _attrPadView.backgroundColor = HexColor(0xCDCDCD);
    [self.contentView addSubview:_attrPadView];
    [_attrPadView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-12);
        make.left.mas_equalTo(self.icon.mas_right).offset(8);
        make.top.mas_equalTo(self.labAttr.mas_bottom).offset(6);
        make.height.mas_equalTo(0.5);
    }];
    
    _detailBtn = UIButton.new;
    _detailBtn.layer.borderColor = kAPPThemeColor.CGColor;
    _detailBtn.layer.borderWidth = 1;
    _detailBtn.layer.cornerRadius = 15;
    _detailBtn.layer.masksToBounds = YES;
    [_detailBtn setTitle:kYQLS(@"查看详情") forState:UIControlStateNormal];
    [_detailBtn setTitleColor:kAPPThemeColor forState:UIControlStateNormal];
    _detailBtn.titleLabel.font = kFont_Medium(13);
    [_detailBtn addTarget:self action:@selector(onClick:) forControlEvents:UIControlEventTouchUpInside];
    _detailBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    [self.contentView addSubview:_detailBtn];
    [_detailBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-12);
        make.width.mas_equalTo(78);
        make.height.mas_equalTo(30);
        make.bottom.mas_equalTo(-10);
    }];
    
    _deleBtn = UIButton.new;
    _deleBtn.layer.borderColor = HexColor(0x999999).CGColor;
    _deleBtn.layer.borderWidth = 1;
    _deleBtn.layer.cornerRadius = 15;
    _deleBtn.layer.masksToBounds = YES;
    [_deleBtn setTitle:kYQLS(@"删除订单") forState:UIControlStateNormal];
    [_deleBtn setTitleColor:HexColor(0x999999) forState:UIControlStateNormal];
    _deleBtn.titleLabel.font = kFont_Medium(13);
    [_deleBtn addTarget:self action:@selector(onClick:) forControlEvents:UIControlEventTouchUpInside];
    _deleBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    [self.contentView addSubview:_deleBtn];
    [_deleBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(self.detailBtn.mas_left).offset(-12);
        make.width.mas_equalTo(78);
        make.height.mas_equalTo(30);
        make.bottom.mas_equalTo(-10);
    }];

    _seperateView = UIView.new;
    _seperateView.backgroundColor = HexColor(0xCDCDCD);
    [self.contentView addSubview:_seperateView];
    [_seperateView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.left.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
        make.height.mas_equalTo(0.5);
    }];
}

- (void)onClick:(UIButton *)button
{
    if ([button.currentTitle isEqualToString:kYQLS(@"删除订单")]) {
        if ([self.delegate respondsToSelector:@selector(selectDeleteBtnWithModel:)]) {
            [self.delegate selectDeleteBtnWithModel:self.refundModel];
        }
    }else if ([button.currentTitle isEqualToString:kYQLS(@"查看详情")]) {
        if ([self.delegate respondsToSelector:@selector(selectDetailBtnWithModel:)]) {
            [self.delegate selectDetailBtnWithModel:self.refundModel];
        }
    }
}

- (void)setRefundModel:(YQRefundOrderModel *)refundModel
{
    _refundModel = refundModel;
    [self.icon sd_setImageWithURL:kURL(refundModel.productPic) placeholderImage:IMAGE_NAMED(@"")];
    
    self.labName.text = refundModel.productName;
    
    self.labAttr.text = refundModel.productAttr;
    
    self.labPrice.text = NSStringFormat(@"HKD%@",kYQLS(refundModel.refundAmount));
    
    self.titleLb.text = kYQLS(@"订单状态");

    if ([refundModel.refundStatus isEqualToString:@"-1"]) {
        self.stateLb.text = kYQLS(@"不可申请");
    }else if([refundModel.refundStatus isEqualToString:@"0"]){
        self.stateLb.text = kYQLS(@"可申请");
    }else if ([refundModel.refundStatus isEqualToString:@"1"]){
        self.stateLb.text = kYQLS(@"申请退款");
    }else if ([refundModel.refundStatus isEqualToString:@"2"]){
        self.stateLb.text = kYQLS(@"申请退货退款");
    }else if ([refundModel.refundStatus isEqualToString:@"3"]){
        self.stateLb.text = kYQLS(@"管理员同意退款");
    }else if ([refundModel.refundStatus isEqualToString:@"4"]){
        self.stateLb.text = kYQLS(@"管理员同意退货退款，待补充物流");
    }else if ([refundModel.refundStatus isEqualToString:@"5"]){
        self.stateLb.text = kYQLS(@"用户已补充物流");
    }else if ([refundModel.refundStatus isEqualToString:@"6"]){
        self.stateLb.text = kYQLS(@"管理员拒绝");
    }else if ([refundModel.refundStatus isEqualToString:@"7"]){
        self.stateLb.text = kYQLS(@"用户撤销");
    }else if ([refundModel.refundStatus isEqualToString:@"8"]){
        self.stateLb.text = kYQLS(@"完成售后");
    }
}
@end
